// Clean email by removeing leading spaces and >
// Date 23:52 29/11/2016
// By Ben a.k.a DreamVB

#include <iostream>
#include <fstream>

const int MAX_LINE = 280;

using namespace std;
using std::cout;
using std::endl;

int main(int argc, char *argv[]){
	int i = 0;
	int j = 0;
	int idx = 0;
	int len = 0;
	char buffer[MAX_LINE];

	if (argc < 2){
		cout << "Usage: " << argv[0] << " <filename>" << endl;
		cout << "\n\tDeveloped by DreamVB" << endl;
		exit(1);
	}

	//Write 6 times table to the file.
	ifstream fs;
	fs.open(argv[1], ios::in);

	//Check if file was opened.
	if (!fs){
		cout << "Cannot open source file." << endl;
		exit(1);
	}

	//Read and display the file.
	while (!fs.eof()){
		//Read line
		fs.getline(buffer, 80);
		//Write line
		if (strlen(buffer)){
			//Get line length
			len = strlen(buffer);

			while (i < len){
				//Skip space
				while (isspace(buffer[i])){
					i++;
				}
				//Check for >
				if (buffer[i] == '>'){
					//Skip over all >
					while (buffer[i] == '>'){
						//INC Counter
						i++;
					}
					//Check for overflow
					if (i > len - 1){ break; }
				}
				else{
					break;
				}
			}
			//Set idx start pos to i
			idx = i;

			//Reset counters
			i = 0;
			j = 0;
			for (i = idx; i < len; i++){
				//Rearrange the buffer
				buffer[j] = buffer[i];
				//INC Counter
				j++;
			}
			//Add ending char
			buffer[j] = '\0';

			cout << buffer << endl;
			//Reset counter
			i = 0;
		}
	}

	//Clear up
	memset(buffer, 0, sizeof(buffer));

	//Close the file.
	fs.close();
	//Return to os
	return EXIT_SUCCESS;
}